
  $('.btn').on('click',function(event){
	var e = window.event || event,
	   ele = e.srcElement || e.target;
	   if(!$(ele).is('input[type="checkbox"]')){
			 var id = $(this).data('id');
			window.location.href="detail.html?id="+id;
	   }
});
  function run(){
			var  type = 1;
			var arr = new Array();
			var num = 0;
			var str = '';
			$('.checkbox').each(function(i){

				var tt = $(this).prop('checked');
				if( tt == true ){
					arr[num++] = $(this).data('id');
				} else{
					type = 0;
				}
			});
			if(type == 0)
			{
				$('.firstbox').prop('checked',false);
			}else
			{
				$('.firstbox').prop('checked',true);
			}

			
			if(num > 0)
			{
				$('th').remove();
				$('.new').remove();


				/*
					<th width="147px">已选择<span>1</span>个候选人</th>
					<th></th>
					<th width="150px"></th><th width="153px"></th>
					<th width="135px"></th>
					<th width="69px">
						<a class="move pagination_blue move-i-pos r35">移动到 <i class=" fa-angle-down fa-lg"></i>
						</a>
						<ul class="move-list pagination_blue ml-35">
							<li>待面试</li>
							<li>全部推荐</li>
							<li>收藏夹</li>
						</ul>
					</th>

					<th width="69px">
						<a class="delete-collection backfe7241 r35">删除收藏
						</a>
					</th>
				 */
			  str += '<th width="147px">已选择<span>'+num+'</span>个候选人</th>';
			  str += '<th></th>';
			  str += '<th width="150px"></th><th width="153px"></th>';
			  str += '<th width="135px"></th>';
			  str += '<th width="69px">';
			  str += '<a class="delete-collection backfe7241 r35" onclick="mus(-1)">删除收藏</a>';
			  str += '</th>';

				$('.firstbox').html(str);

			}else
			{
				$('.new').remove();
				$('th').remove();
				$('.firstbox').html('<th  width="147px"> 候选人 </th><th width="156px"> 推荐职位 </th><th width="150px"> 推荐时间 </th><th width="153px"> 推荐猎头 </th><th width="135px"> 推荐状态 </th><th width="69px"> 选择 </th>');
			}
		}

		function sucs()
		{
			var cid = new Array();
				$('.checkbox:checked').each(function(i){
					cid[i] = $(this).val();
				});
			if (cid.length == 0) {
				  alert('没有选中信息');
					return false;
				}
		   $.post(
			'?r=agency/comcode/agree',
			{'cid':cid, '_csrf': $('.request-csrf').val()},
			function (res) {
				// res = eval('('+res+')');
				// res = eval('('+res+')');
				if (res.code == 400) alert(res.msg);
				location.reload();
			}
			);
			return false;
		}


		function dbug()
		{
			$('.checkbox').prop('checked',false);
			$('.new').remove();
				$('.firstbox').append('<th  width="147px"> 候选人 </th><th width="156px"> 推荐职位 </th><th width="150px"> 推荐时间 </th><th width="153px"> 推荐猎头 </th><th width="135px"> 推荐状态 </th><th width="69px"> 选择 </th>');
		}


		function move()
		{
			if ($(".move i").attr("class") == "fa-angle-down fa-lg") {
				$(".move i").removeClass("fa-angle-down fa-lg");
				$(".move i").addClass("fa-angle-up fa-lg");
			} else {
				$(".move i").removeClass("fa-angle-up fa-lg");
				$(".move i").addClass("fa-angle-down fa-lg");

			}
			$(".move-list").toggle()
			

		}


run();

function mus(sta)
{
	var value_id = new Array();

	$('.checkbox:checked').each(function(i){
		value_id[i] = $(this).data('id');
	});

	$.post(
		'move.html',
		{'sta':sta,'value_id':value_id,'_csrf':$('.request-csrf').val()},
		function(res)
		{
			res = eval('('+res+')');

			if(res.code == 400)
			{
				alert(res.msg);
			}else
			{
				location.reload(); 
			}
		});   
}
